<!DOCTYPE html>
<html>
{include file="head.html"}
<body>
<div class="body">
{include file="header.html"}
<div class="main-body box960">
  <div class="row">
    <div class="col-6-1">{include file='user_left.html'}</div>
    <div class="col-6-5"> {include file='shop_flash/nav.html'}
      <form method='post' action='shopadmin.php?m=shop_flash&a=save'>
        <input type='hidden' name='id' style='display:none;' value='{$data.id}' >
        <table class='table table-bordered' width='100%'>
          <tr>
            <td width="100">标题：</td>
            <td><input type='text' name='title' id='title' class="w300" value='{$data.title}' ></td>
          </tr>
           
          <tr>
            <td>链接：</td>
            <td><input type='text' name='linkurl' id='linkurl' class="w300" value='{$data.linkurl}' > (新品链接)</td>
          </tr>
          <tr>
            <td>排序：</td>
            <td><input type='text' name='orderindex' id='orderindex' value='{$data.orderindex}' > (小的排前面)</td>
          </tr>
          <tr>
    <td align="right">图片：</td>
    <td>
    <div class="btn-upload">
      <input type="file" name="upimg" class="btn-upload-file" id="upimg" onChange="uploadgoodsimg()">
      </div>
      <label  id="loading" style="color:red; display:none;">正在上传中...</label>
      <input type="hidden" name="imgurl" id="imgurl" value="{$data.imgurl}">
      <span id="imgShow">
      {if $data.imgurl}
          <img src="{$data.imgurl|images_site}.100x100.jpg">
          {/if}
      </span>
      </td>
  </tr>
          
          <tr>
            <td></td>
            <td><input type='submit' value='保存' class='btn btn-success'></td>
          </tr>
        </table>
      </form>
    </div>
  </div>
</div>
<script language="javascript" src="/plugin/jquery/ajaxfileupload.js"></script>
<script language="javascript">
   function uploadgoodsimg()
    {
        //starting setting some animation when the ajax starts and completes
        $("#loading")
        .ajaxStart(function(){
            $(this).show();
        })
        .ajaxComplete(function(){
            $(this).hide();
        });

        $.ajaxFileUpload
        (
            {
                url:'/index.php?m=upload&a=uploadtao&dir=product&siteid={const.SITEID}&id={$data.id}&t='+Math.random(), 
                secureuri:false,
                fileElementId:'upimg',
                dataType: 'json',
                success: function (data, status)
                {
                    if(typeof(data.error) != 'undefined')
                    {
                        if(data.error != '')
                        {
                           alert(data.msg);
                        }else
                        {
                             $("#imgShow").html("<img src='/"+data.imgurl+".100x100.jpg' width='100'>");
							 $("#imgurl").val(data.imgurl);
                        }
                    }
                },
                error: function (data, status, e)
                {
					alert(data.msg)
  
                }
            }
        )
        
        return false;

    }
</script>
{include file="footer.html"}
